<template name="browseCollection">
    {{#if getSelectedCollection}}
        {{> pageHeading title=getSelectedCollection }}
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>{{_ "query"}}
                                <small>{{getSelectedCollection}}</small>
                            </h5>
                            <div class="ibox-tools">
                                <a id="btnQueryWizard" href="#" title="{{_ "wizard"}}">
                                    <i class="fa fa-magic"></i>
                                </a>
                                <a id="btnExportQueryResult" href="#"
                                   aria-expanded="false"
                                   class="dropdown-toggle fix-button" data-toggle="dropdown"
                                   title="{{_ "export"}}">
                                    <i class="fa fa-upload"></i>
                                </a>
                                <ul class="dropdown-menu dropdown-tasks">
                                    <li>
                                        <a id="btnExportAsCSV" href="">
                                            <i class="fa fa-file"></i> {{_ "csv"}}
                                        </a>
                                    </li>
                                    <li><a id="btnExportAsJSON" href="#"><i class="fa fa-file"></i>
                                        {{_ "json"}}</a></li>
                                </ul>

                                <a id="btnSwitchView" href="#"
                                   title="{{_ "switch_result_view"}}">
                                    <i class="fa fa-exchange"></i>
                                </a>
                                <a id="btnShowQueryHistories" href="#"
                                   title="{{_ "history"}}">
                                    <i class="fa fa-history"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <form class="form-horizontal">
                                <div class="form-group">
                                    <label class="col-lg-1 control-label">{{_ "query"}}</label>
                                    <div class="col-lg-11">
                                        <select id="cmbQueries"
                                                data-placeholder="{{_ "choose_query"}}"
                                                class="chosen-select form-control"
                                                tabindex="-1">
                                            <option></option>
                                        </select>
                                        <span class="help-block m-b-none">{{{getHelpBlockForSelectedQuery}}}</span>
                                    </div>
                                </div>

                                {{> Template.dynamic template=getQueryTemplate}}

                                <div class="form-group">
                                    <div class="col-lg-12">
                                        <button id="btnExecuteQuery"
                                                class="btn btn-block btn-outline btn-primary ladda-button"
                                                type="button"
                                                data-style="contract"><strong>{{_ "execute"}}</strong></button>
                                    </div>
                                </div>
                                <ul id="resultTabs" class="nav nav-tabs">
                                </ul>
                                <div id="resultTabContents" class="tab-content">
                                </div>
                            </form>
                        </div>
                        <div class="ibox-footer" id="divBrowseCollectionFooter" style="display: none;">
                            <div class="row">
                                <div class="col-lg-6">
                                    <button id="btnDelFindOne"
                                            class="btn btn-block btn-outline btn-primary ladda-button"
                                            type="button"
                                            data-style="contract">
                                        <strong>{{_ "delete"}}</strong></button>
                                </div>
                                <div id="divSaveFindOne" class="col-lg-6">
                                    <button id="btnSaveFindOne"
                                            class="btn btn-block btn-outline btn-primary ladda-button"
                                            type="button"
                                            data-style="contract">
                                        <strong>{{_ "save"}}</strong></button>
                                </div>
                            </div>
                        </div>
                        <div class="ibox-footer" id="divBrowseCollectionFindFooter" style="display: none;">
                            <div class="row">
                                <div id="divSaveFind" class="col-lg-12">
                                    <button id="btnSaveFind"
                                            class="btn btn-block btn-outline btn-primary ladda-button"
                                            type="button"
                                            data-style="contract">
                                        <strong>{{_ "save"}}</strong></button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        {{> queryHistories}}

    {{/if}}
</template>
